import 'package:any_reader/public.dart';

class Rule {
  String name;
  String reptileTypeId;
  String reason;
  Rule({
    Key key,
    @required this.name,
    @required this.reptileTypeId,
    @required this.reason,
  });
  factory Rule.fromJson(String name, String reptileTypeId, String reason) {
    return Rule(name: name, reptileTypeId: reptileTypeId, reason: reason);
  }
  static List<Rule> listFromJson(Map<String, dynamic> json) {
    List<Rule> _list = [];
    List<dynamic> reptileList = json['reptileList'];
    reptileList.forEach((value) {
      _list.add(Rule.fromJson(
        value['name'].toString(),
        value['reptileTypeId'].toString(),
        value['reason'].toString(),
      ));
    });
    print("$_list");
    return _list;
  }

  static List<Rule> listFromDatabase(List<Map<String, dynamic>> result) {
    List<Rule> _list = [];
    result.forEach((Map<String, dynamic> row) {
      _list.add(Rule.fromJson(
        row['name'].toString(),
        row['reptile_type_id'].toString(),
        row['reason'].toString(),
      ));
    });
    return _list;
  }
}
